﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PServiceBus.Services.Gateway.Runtime;
using InvokeWebService.Messages;
using System.Configuration;

namespace WebServiceServer {
    public partial class WebForm1 : System.Web.UI.Page {
        static WebForm1() {
            Topic.RegisterIfNotExist<WebServiceInvokeCompleted>();
        }

        protected void Page_Load(object sender, EventArgs e) {
            if (Request.Form["to"] == null) return;
            var msg = new WebServiceInvokeCompleted() {
                Message = String.Format("Hello World {0} from web application", Request.Form["to"])
            };
            Topic
                .Select<WebServiceInvokeCompleted>()
                .SetHeader("HostName", HttpContext.Current.Request.UserHostName)
                .SetHeader("Url", HttpContext.Current.Request.Url.ToString())
                .Publish(msg);
        }
    }
}